package PantallasCliente;
import ControlCliente.ManejadorCrearPartida;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class PantallaErrorCrearPartida implements ActionListener, WindowListener {

/************atributos*******************************************/
    private JFrame ventanaErrorCrearPartida;
    private ManejadorCrearPartida mcp;
/*****************************************************************/

/************métodos**********************************************/
    public PantallaErrorCrearPartida(){}
    public PantallaErrorCrearPartida(ManejadorCrearPartida mcp) {
        this.mcp = mcp;
        crearPantalla();
        mostrarPantalla();
    }

    public void crearPantalla(){
        ventanaErrorCrearPartida = new JFrame("El Juego");
        ventanaErrorCrearPartida.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ventanaErrorCrearPartida.setBounds(100, 100, 400, 300);
        ventanaErrorCrearPartida.getContentPane().setLayout(null);
        ventanaErrorCrearPartida.addWindowListener(this);

        JLabel txt0 = new JLabel("Ocurrio un error al intentar crear la partida. Por favor vuelva a intentar");
        txt0.setBounds(15, 100, 350, 20);
        ventanaErrorCrearPartida.getContentPane().add(txt0);

        JButton aceptar = new JButton("Aceptar");
        aceptar.setBounds(80, 250, 100, 20);
        ventanaErrorCrearPartida.getContentPane().add(aceptar);
        aceptar.setMnemonic(KeyEvent.VK_A);
        aceptar.setActionCommand("aceptar");
        aceptar.addActionListener(this);
    }
    public void mostrarPantalla(){
        ventanaErrorCrearPartida.setVisible(true);
    }
    public void ocultarPantalla(){
        ventanaErrorCrearPartida.setVisible(false);
    }
    public void actionPerformed(ActionEvent e) {
         if ("aceptar".equals(e.getActionCommand())){
            ventanaErrorCrearPartida.setVisible(false);
            mcp.mostrarPantallaCrearPartida();
         }
    }

    public void windowOpened(WindowEvent e) { }
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
    public void windowClosed(WindowEvent e) {
        System.exit(0);
    }
    public void windowIconified(WindowEvent e) { }
    public void windowDeiconified(WindowEvent e) { }
    public void windowActivated(WindowEvent e) { }
    public void windowDeactivated(WindowEvent e) { }
/*****************************************************************/
    }